// 堆叠条形图

export default function getStackLine(optionSet = []) {

  console.log('optionSet: ', optionSet);
  const res = [];
  let yData = [];
  let legend = [];
  if (optionSet.length) {
    yData = optionSet[0].data.map(i => i.name);
    legend = optionSet.map(i => i.label);
    optionSet.forEach((i, index) => {
      res.push({
        name: i.label,
        type: 'bar',
        stack: '总量',
        label: {
          normal: {
            show: true,
            position: 'insideRight'
          }
        },
        data: i.data.map(j => j.value)
      });
    });
  }

  console.log('res', res);
  const option = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        // 坐标轴指示器，坐标轴触发有效
        type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
      }
    },
    legend: {
      data: legend
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'value'
    },
    yAxis: {
      type: 'category',
      data: yData
    },
    series: res
  };

  return option;
}
